package at.main.android;

import java.io.IOException;

public class Manager {
	public static Player createPlayer(String sFile, String sType) throws IOException  {
		sFile=sFile.toLowerCase();
		boolean isSFX = true;
		if(sType.toLowerCase().equals("audio/midi") || sType.toLowerCase().equals("audio/mpegv"))
			isSFX = false;
		//if(sType.toLowerCase().equals("audio/x-smaf")) //if(sType.toLowerCase().equals("audio/x-wav")) //if(sType.toLowerCase().equals("audio/mpegv"))
		int b = sFile.lastIndexOf('/');
		int e = sFile.lastIndexOf('.');
		if(e==0) e = sFile.length();
		if(e-b>1)
			sFile = sFile.substring(b+1, e);
		else
			return null;

		int id = Static.App.getResources().getIdentifier(sFile, "raw", Static.App.getPackageName());
		if(id != 0)
			return new Player(id, isSFX);
		
		return null;
	}
}
